﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using SapB1WebApp.Utils;
using SapB1WebApp.DAL;

namespace SapB1WebApp.BLL
{
    public class GoodReceiptPOBLL
    {
        public DataSet GetDocuments(string companyDB)
        {
            try
            {
                GoodReceiptPODAO connect = new GoodReceiptPODAO();
                DataSet dt = new DataSet(TableNameDefined.GOOD_RECEIPT_PURCHASE_ORDER_HEADER);
                dt = connect.GetOPDN(companyDB);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataSet GetDocumentByDocEntry(string companyDB, string docEntry)
        {
            try
            {
                DataSet dt = new DataSet(TableNameDefined.GOOD_RECEIPT_PURCHASE_ORDER_HEADER);
                GoodReceiptPODAO connect = new GoodReceiptPODAO();
                dt = connect.GetOPDNByDocEntry(companyDB, docEntry);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataSet GetDocumentForSearch(string companyDB, string keySearch)
        {
            try
            {
                DataSet dt = new DataSet(TableNameDefined.GOOD_RECEIPT_PURCHASE_ORDER_HEADER);
                GoodReceiptPODAO connect = new GoodReceiptPODAO();
                dt = connect.GetOPDNForSearch(companyDB, keySearch);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataSet GetDocumentLastRecord(string companyDB)
        {
            try
            {
                DataSet dt = new DataSet(TableNameDefined.GOOD_RECEIPT_PURCHASE_ORDER_HEADER);
                GoodReceiptPODAO connect = new GoodReceiptPODAO();
                dt = connect.GetOPDNLastRecord(companyDB);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataSet GetDocumentLineByDocEntry(string companyDB, string docEntry)
        {
            try
            {
                DataSet dt = new DataSet(TableNameDefined.GOOD_RECEIPT_PURCHASE_ORDER_LINE);
                GoodReceiptPODAO connect = new GoodReceiptPODAO();
                List<object> lstParamValue = new List<object>();
                lstParamValue.Add(docEntry);
                dt = connect.GetPDN1ByDocEntry(companyDB, docEntry);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
    }
}